package com.itec.learn.java.collections.list;

import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

/**
 * @author chenyiqun
 */
public class LearnList {

    public static void main(String[] args) {
        //基于数组，默认大小为10，有容量限制
        List<Integer> arrayList = new ArrayList<Integer>(10);
        arrayList.add(1);
        arrayList.add(2);
        arrayList.add(3);

        Collections.synchronizedList(arrayList);

        //双向链表，无容量限制
        LinkedList<Integer> linkedList = new LinkedList<Integer>();
        linkedList.add(1);
        linkedList.add(2);
        linkedList.add(3);
        linkedList.push(4);
        linkedList.push(6);
        int v= linkedList.pop();
        System.out.println(v);
        System.out.println(linkedList);


        //并发优化的ArrayList
        CopyOnWriteArrayList<Integer> copyOnWriteArrayList = new CopyOnWriteArrayList<Integer>();
        copyOnWriteArrayList.add(1);
        copyOnWriteArrayList.add(2);
        copyOnWriteArrayList.add(3);

    }

}
